package com.aloda.mapper;

import com.aloda.entity.Address;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressMapper {

    @Select("select count(*) from supermarket.address_book where user_id = #{id}")
    int getAddressNum(Long id);

    @Insert("insert into supermarket.address_book(user_id, consignee, gender, phone, province_code, province_name, city_code, city_name, district_code, district_name, detail, label) " +
            "value (#{userId},#{consignee},#{gender},#{phone},#{provinceCode},#{provinceName},#{cityCode},#{cityName},#{districtCode},#{districtName},#{detail},#{label})")
    void insert(Address address);

    @Select("select * from supermarket.address_book where user_id = #{id}")
    List<Address> getAddressByUserId(Long id);
}
